<?php
class IM_C_ManageHome extends BaseController{
	public function start(){
		fw_util_custom_doLoginCheck();
		$this->registry->template->arr_jsScriptUrls = $this->arr_appConf['js_files'];
		$this->registry->template->arr_cssSriptUrls = $this->arr_appConf['css_style_sheets'];
		$this->getSubNavi();
		$this->registry->template->show('Admin-ManageHome.php');
	}
	
	public function runMultiFileUpload(){
		fw_util_custom_doLoginCheck();
		/*
		 * jQuery File Upload Plugin PHP Example 5.7
		 * https://github.com/blueimp/jQuery-File-Upload
		 *
		 * Copyright 2010, Sebastian Tschan
		 * https://blueimp.net
		 *
		 * Licensed under the MIT license:
		 * http://www.opensource.org/licenses/MIT
		 */
		
		//error_reporting(E_ALL | E_STRICT);
			require(C_FW_fwPackage. 'libraries/jqueryFileUpload/php/' . 'upload.class.php');
			$arr_options = array(
				'script_url'=> fw_util_getFullUrl(). '/AdminManageHome/runMultiFileUpload', 
				'upload_dir'=> C_FW_frontendPackage . 'slideshowimages/',
				'upload_url'=> C_FW_TRUEURL.C_FW_frontendPackage . 'slideshowimages/',
		 		'image_versions' => array(
					'thumbnail' => array(
						'upload_dir' => C_FW_frontendPackage . 'slideshowimages/thumbs/',
						'upload_url' => C_FW_TRUEURL.C_FW_frontendPackage . 'slideshowimages/thumbs/',
						'max_width' => 960,
						'max_height' => 494
					)
				)
			);
			
			$upload_handler = new UploadHandler($arr_options);
			
			switch ($_SERVER['REQUEST_METHOD']) {
			    case 'OPTIONS':
			        break;
			    case 'HEAD':
			    case 'GET':
			        $upload_handler->get();
			        break;
			    case 'POST':
			        if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
			            $upload_handler->delete();
			        } else {
			           	$upload_handler->post();
			            //print_r($arr_picInfo);
			            $arr_picInfo = $upload_handler->getCurrPicInfo();
			        }
			        break;
			    case 'DELETE':
			        $upload_handler->delete();
			        $s_fileName = $upload_handler->getCurrFileNameForDelete();
			        break;
			    default:
			        header('HTTP/1.1 405 Method Not Allowed');
			}
	}
}